.admonition {
  position: relative;
  margin: 1rem 0;
  padding: 0 0.75rem;
  border-left: .25rem solid;
  overflow: hidden;
  @include border-radius($global-border-radius);

  .admonition-title {
    font-weight: var(--admonition-title-font-weight, bold);
    margin: 0 -0.75rem;
    padding: 0.25rem 1.8rem;
    border-bottom: 1px solid;
    @include border-radius(0);

    strong {
      font-weight: bolder;
      text-shadow: 0 0.05rem 0.05rem rgba(0, 0, 0, 0.2);

      [data-theme='dark'] & {
        text-shadow: 0 0.05rem 0.05rem rgba(255, 255, 255, 0.2);
      }
    }

    &:has(+ .details-content > .admonition-content:empty) {
      --admonition-title-font-weight: normal;
    }
  }

  .admonition-content {
    padding: 0.5rem 0;
    
    // for extended alert syntax
    > p {
      margin: 0;
    }
    // title-only alert
    &:empty {
      display: none;
    }
  }

  i.icon {
    font-size: 0.85rem;
    position: absolute;
    top: 0.6rem;
    left: 0.4rem;
  }

  i.details-icon {
    position: absolute;
    top: 0.6rem;
    right: 0.3rem;
  }
  
  background-color: var(#{$rootPrefix}admonition-bg-color);
  border-left-color: var(#{$rootPrefix}admonition-color);

  > .admonition-title {
    border-bottom-color: var(#{$rootPrefix}admonition-bg-color);
    background-color: var(#{$rootPrefix}admonition-bg-color-collapsed);

    i.icon {
      color: var(#{$rootPrefix}admonition-color);
    }
  }

  &.open > .admonition-title {
    background-color: var(#{$rootPrefix}admonition-bg-color);
  }

  // default admonition type is note
  #{$rootPrefix}admonition-color: #{map-get(map-get($admonition-color-map, note), color)};
  #{$rootPrefix}admonition-bg-color: #{map-get(map-get($admonition-color-map, note), bg-color)};
  #{$rootPrefix}admonition-bg-color-collapsed: #{opacify(map-get(map-get($admonition-color-map, note), bg-color), 0.15)};

  // set color for each admonition type
  @each $type, $item in $admonition-color-map {
    @if $type != 'note' {
      &.#{$type} {
        #{$rootPrefix}admonition-color: #{map-get($item, color)};
        #{$rootPrefix}admonition-bg-color: #{map-get($item, bg-color)};
        #{$rootPrefix}admonition-bg-color-collapsed: #{opacify(map-get($item, bg-color), 0.15)};
      }
    }
  }

  &:last-child {
    margin-bottom: 0.75rem;
  }
}
